package com.joyplus.report.business.controller;

import com.joyplus.report.business.document.DistributionPvUvStatisticsDocument;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by  2018/5/29.
 */
@RequestMapping(value = "test")
public class TestController {

  @Autowired
  MongoTemplate mongoTemplate;

  @GetMapping
  public void contextLoads() {


    Query query = new Query();
    query.addCriteria(Criteria.where("campaign_id").is("750"));
    List<DistributionPvUvStatisticsDocument> dailyPvUvs = mongoTemplate.findAll(DistributionPvUvStatisticsDocument.class);
    List<DistributionPvUvStatisticsDocument> distributionPvUvStatisticsDocuments = mongoTemplate
        .find(query, DistributionPvUvStatisticsDocument.class);
   /* Aggregation aggregation = Aggregation.newAggregation(
        Aggregation.match(Criteria.where("campaign_id").is("750")),
        Aggregation.group("date","campaign_id"),
        Aggregation.project("pv","uv","date","campaign_id")
    );*/

    // mongoTemplate.aggregate((TypedAggregation<?>) Aggregation.newAggregation(Aggregation.match(Criteria.where("campaign_id").is("750"))),DistributionPvUvStatisticsDocument.class)
  }



}
